updating oE pairs

pairs

include map.e 
namespace map 
public function pairs(map the_map, integer sorted_result = 0) 

returns all key:value pairs in a map.

Parameters:
  1. the_map_p : the map to get the data from
  2. sorted_result : optional integer. 0 [default] means do not sort the output and 1 means to sort the output before returning.
Returns:

A sequence, of all key:value pairs stored in the_map_p. Each pair is a sub-sequence in the form {key, value}

Comments:

If sorted_result is not used, the order of the values returned is not predicable.

Example 1:
map the_map_p 
 
the_map_p = new() 
put(the_map_p, 10, "ten") 
put(the_map_p, 20, "twenty") 
put(the_map_p, 30, "thirty") 
put(the_map_p, 40, "forty") 
 
sequence keyvals 
keyvals = pairs(the_map_p)  
-- might be {{20,"twenty"},{40,"forty"},{10,"ten"},{30,"thirty"}} 
 
keyvals = pairs(the_map_p, 1)  
-- will be {{10,"ten"},{20,"twenty"},{30,"thirty"},{40,"forty"}} 
See Also:

get, keys, values

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu